import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "Home",
    redirect: "/sold",
    component: Home,
    children: [
      {
        path: "/sold",
        name: "Sold",
        component: () => import("@/views/Sold.vue"),
      },
      {
        path: "/supply",
        name: "Supply",
        component: () => import("@/views/Supply.vue"),
      },
      {
        path: "/buyer",
        name: "Buyer",
        component: () => import("@/views/Buyer.vue"),
      },
      {
        path: "/project",
        name: "Project",
        component: () => import("@/views/Project.vue"),
      },
      {
        path: "/practitionSubject",
        name: "PractitionSubject",
        component: () => import("@/views/PractitionSubject.vue"),
      },
    ],
  },
];

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};

const router = new VueRouter({
  routes,
});

export default router;
